from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, SubmitField, FloatField, IntegerField, SelectField
from wtforms.validators import DataRequired, Length, NumberRange, InputRequired

DEPARTMENTS = [
    "数学学院",
    "马克思主义学院",
    "数学学院",
    "计算机科学与技术学院",
    "外国语学院",
    "软件学院",
    "数学学院",
]

STUDENT_STATUS = [
    "本科", "硕士", "博士"
]

PROFESSOR_STATUS = [
    "讲师", "副教授", "教授"
]


# 用于添加新学生
class NewStudentForm(FlaskForm):
    student_id = IntegerField('学号', validators=[DataRequired()])
    password = StringField('初始密码', validators=[DataRequired()])
    student_name = StringField('姓名', validators=[DataRequired()])
    date_of_birth = StringField('出生年月日(格式如：2020-01-05)', validators=[DataRequired()])
    social_security_number = StringField('身份证号码(格式如：85467219)', validators=[DataRequired()])
    status = SelectField('学历', validators=[DataRequired()], choices=[(t, t) for t in STUDENT_STATUS])
    graduation_date = StringField('毕业日期', validators=[DataRequired()])
    department = SelectField('学院', validators=[DataRequired()], choices=[(t, t) for t in DEPARTMENTS])
    balance = FloatField('初始余额(CNY)', validators=[InputRequired()])
    submit = SubmitField('确认添加学生')


# 用于搜索学生，进行删除
class StudentForm(FlaskForm):
    student_id = IntegerField('学号', validators=[DataRequired()])
    submit = SubmitField('确定')


# 用于更新学生信息，这里只有学号是必填
class UpdateStudentForm(FlaskForm):
    student_id = IntegerField('学号', validators=[DataRequired()])
    password = StringField('初始密码')
    student_name = StringField('姓名')
    date_of_birth = StringField('出生年月日(格式如：1999-03-14)')
    social_security_number = StringField('身份证号码(格式如：85467219)')
    status = SelectField('学历', choices=[(t, t) for t in STUDENT_STATUS])
    graduation_date = StringField('毕业日期(格式如：2020-06-15)')
    department = SelectField('学院', choices=[(t, t) for t in DEPARTMENTS])
    submit = SubmitField('确认更新学生信息')


# -------------------------------------------
# 用于教师的表单，类似于上面对于学生的表单
class NewProfessorForm(FlaskForm):
    professor_id = IntegerField('教师工号', validators=[DataRequired()])
    password = StringField('初始密码', validators=[DataRequired()])
    professor_name = StringField('姓名', validators=[DataRequired()])
    date_of_birth = StringField('出生年月日(格式如：1972-01-05)', validators=[DataRequired()])
    social_security_number = StringField('身份证号码(格式如：85467219)', validators=[DataRequired()])
    status = SelectField('职称', validators=[DataRequired()], choices=[(t, t) for t in PROFESSOR_STATUS])
    department = SelectField('学院', validators=[DataRequired()], choices=[(t, t) for t in DEPARTMENTS])
    submit = SubmitField('确认添加教师')


class ProfessorForm(FlaskForm):
    professor_id = IntegerField('教师工号', validators=[DataRequired()])
    submit = SubmitField('确定')


class UpdateProfessorForm(FlaskForm):
    professor_id = IntegerField('教师工号', validators=[DataRequired()])
    password = StringField('密码')
    professor_name = StringField('姓名')
    date_of_birth = StringField('出生年月日(格式如：1972-01-05)')
    social_security_number = StringField('身份证号码(格式如：85467219)')
    status = SelectField('职称', choices=[(t, t) for t in PROFESSOR_STATUS])
    department = SelectField('学院', choices=[(t, t) for t in DEPARTMENTS])
    submit = SubmitField('确认更新教师信息')
